import debounce from '@/utils/util';
export default {
    methods:{
        loadScroll(scrollBox,callback){
            let clientHeight = scrollBox.clientHeight;  //盒子的高度
            scrollBox.loadFun = debounce(() =>{
                //盒子的高度+滚动的高度 <= 内容部分高度-20
                let pageHeight = this.$refs.pagelist.offsetHeight;
                if((clientHeight + scrollBox.scrollTop) >= (pageHeight-20)){
                    callback && callback()
                }
            },1000)

            scrollBox.addEventListener('scroll',scrollBox.loadFun)
        },
        beforeDestroy() {
            this.$refs.pagelist.parentNode && this.$refs.pagelist.parentNode.removeEventListener('scroll', this.$refs.pagelist.parentNode.loadFun)
        }
    }
}